Total Complexity | 2 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import {Entity, Column, PrimaryGeneratedColumn, ManyToOne} from 'typeorm'; |
||
5 | |||
6 | @Entity() |
||
7 | export class Quote { |
||
8 | public static readonly STATUS_DRAFT = 'draft'; |
||
9 | public static readonly STATUS_SENT = 'sent'; |
||
10 | public static readonly STATUS_REFUSED = 'refused'; |
||
11 | public static readonly STATUS_ACCEPTED = 'accepted'; |
||
12 | public static readonly STATUS_CANCELED = 'canceled'; |
||
13 | |||
14 | public static getAvailableStatus(): string[] { |
||
15 | return [ |
||
16 | Quote.STATUS_DRAFT, |
||
17 | Quote.STATUS_SENT, |
||
18 | Quote.STATUS_REFUSED, |
||
19 | Quote.STATUS_ACCEPTED, |
||
20 | Quote.STATUS_CANCELED |
||
21 | ]; |
||
22 | } |
||
23 | |||
24 | @PrimaryGeneratedColumn('uuid') |
||
25 | private id: string; |
||
26 | |||
27 | @Column({type: 'varchar', nullable: false}) |
||
28 | private status: string; |
||
29 | |||
30 | @Column({type: 'varchar', nullable: false, unique: true}) |
||
31 | private quoteId: string; |
||
32 | |||
33 | @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'}) |
||
34 | private createdAt: Date; |
||
35 | |||
36 | @ManyToOne(type => User, {nullable: false}) |
||
37 | private owner: User; |
||
38 | |||
39 | @ManyToOne(type => Customer, {nullable: false}) |
||
40 | private customer: Customer; |
||
41 | |||
42 | @ManyToOne(type => Project, {nullable: true}) |
||
43 | private project: Project; |
||
44 | |||
45 | constructor( |
||
46 | quoteId: string, |
||
47 | status: string, |
||
48 | owner: User, |
||
49 | customer: Customer, |
||
50 | project?: Project | null |
||
51 | ) { |
||
52 | this.quoteId = quoteId; |
||
53 | this.status = status; |
||
54 | this.owner = owner; |
||
55 | this.customer = customer; |
||
56 | this.project = project; |
||
57 | } |
||
58 | |||
59 | public getId(): string { |
||
60 | return this.id; |
||
61 | } |
||
63 |